<div class="layui-body-header">
  <ul class="kit-breadcrumb">
    <li class="kit-item">
      <a href="javascript:;">
        <i class="layui-icon">&#xe68e;</i>
        <span>数据库备份</span>
      </a>
    </li>
  </ul>
</div>
<div class="layui-fluid">
	<div class="layui-row">
		<div class="layui-col-xs12">
			<div class="layui-card">
				<div class="layui-card-header">
					<button class="layui-btn layui-btn-sm backup">备份当前</button>
				</div>
				<div class="layui-card-body">
					<table id="test" lay-filter="test" ></table>
            <!--<script type="text/html" id="bartest">
            	<a class="layui-btn layui-btn-xs" lay-event="xiangqing">考勤</a>
              <a class="layui-btn layui-btn-xs" lay-event="detail">编辑</a>
              <a class="layui-btn layui-btn-xs" lay-event="watchMem">统计</a>
            </script>-->
					<!--<table class="layui-table baupInfo-table " >
						<tbody>
							
								<tr class="center">
									<th>文件名称</th>
									<th>备份时间</th>
									<th>操作</th>
									
								</tr>
							
							
							<tr class="center">
								<td>asdfkjslfjeijosfd</td>
								<td>2018/9/12 00:08:26</td>
								<td><button class="layui-btn layui-btn-xs">删除</button></td>
								
							</tr>
						</tbody>
					</table>-->
				</div>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	
	let backup = document.querySelector(".backup")
	
	
	layui.config({
    base: '/src/js/'
  }).use(['jquery', 'mockjs', 'table', 'sidebar', 'form' , 'route' , 'laydate'], function () {
    var $ = layui.jquery,
      layer = layui.layer,
      table = layui.table,
      sidebar = layui.sidebar,
      laydate = layui.laydate,
      route = layui.route,
      params = route.params(),
      form = layui.form;
      
      
      renderForm();
      
      
    //第一个实例
    table.render({
      method: 'get',
      // size: 'sm',
      limit: 10000,
      limits: [10,20,30],
      elem: '#test',
      height: 'full-235',
      contentType: 'application/json',
      url: 'https://xnsmb.xnsoft.net.cn/api/GetDatabase', //数据接口
			parseData: function(res){
      	return {
      		'code':0,
      		
      		"data":res
      	};
      },
//    where: {
////    	"MemLoginId": "",
//			  "CircleGuid": params.id,
//			  "StartTime": "",
//			  "EndTime": "",
//			  "OperateType": 2,
//    },
      request: {
		    pageName: 'CurrentPage' //页码的参数名称，默认：page
		    ,limitName: 'PageSize' //每页数据量的参数名，默认：limit
		  },
      page: false, //开启分页
      cols: [
        [ //表头
        {
            field: '0',
            title: '文件名称',
            align: 'center',
//          width: 150
          }, {
            field: '1',
            title: '备份时间',
            align: 'center',
//          width: 150
          }
        ]
      ]
    });
    
    function renderForm(){
		  layui.use('form', function(){
		   var form = layui.form;//高版本建议把括号去掉，有的低版本，需要加()
		   form.render();
		  });
		}
    
    backup.addEventListener("click",function(){
    	DBHelper.Post("DatabaseBackup","",function(data){
    		console.log(data)
    		let index = layer.alert("备份成功",function(){
    			location.href = window.location.href
    			layer.close(index)
    		})
    	},function(data){
    		let index = layer.alert("备份失败",function(){
    			console.log(data)
//  			location.href = window.location.href
    			layer.close(index)
    		})
    	})
    })
    
    })
	
	
</script>


<style scoped>
		.listBtns{
			margin-top: 20px;
			margin-bottom: 20px;
		}
		.baupInfo-table{
			font-size: 12px;
		}
		.baupInfo-table tr>th{
			text-align: center;
			font-size: 12px;
		}
		.baupInfo-table tr>td{
			text-align: center;
			font-size: 12px;
		}
      	.block{
      		display: block;
      	}
      	.baupTop-btn{
      		width: 100%;
      		text-align: center;
      	}
      	.baupInfo{
      		margin-top: 20px;
      		margin-bottom: 30px;
      	}
      	.baupTop-btn button{
      		display: inline-block;
      		width: 200px;
      		border-radius: 5px;
      	}
      	.title{
      		margin-left: 30px;
      		margin-top: 30px;
      	}
      	.save-warp{
      		width: 100%;
      		text-align: center;
      		margin-top: 20px;
      	}
      	.save-warp button{
      		display: inline-block;
      		width: 160px;
      	}
      	.baup-top{
      		display: flex;
      		justify-content: space-between;
      	}
      	.baup-table{
      		background-color: rgba(0,0,0,0);
      	}
      	
      	
      </style>
      
      



